
import { HashRouter, BrowserRouter, Route, Routes, Link } from "react-router-dom"
import { Provider } from "react-redux"
import store from "./store/index"

import Layout from "@/pages/layout/index"
import Login from "@/pages/login/index"
import Dashboard from "@/pages/dashboard/index"
import GoodList from "@/pages/good/goodList"
import GoodAdd from "@/pages/good/goodForm"
import User from "@/pages/user/index"

import { asyncRoutes } from "@/pages/index.jsx"
// 为了实现动态主题  切换动态主题颜色
import 'antd/dist/antd.variable.min.css';

function createRoutes(accessRoutes) {
    let result = [];
    accessRoutes.forEach(route => {
        if (route.path && route.element) {
            result.push(
                <Route key={route.key} path={route.path} element={route.element}></Route>
            )
        }
        if (route.children) {
            route.children.forEach(route => {
                result.push(
                    <Route key={route.key} path={route.path} element={route.element}></Route>
                )
            })
        }
    })
    return result;
}

function App() {
    return (
        <HashRouter>
            <Provider store={store}>
                <Routes>
                    <Route path="/" element={<Layout />}>
                        {
                            createRoutes(asyncRoutes)
                        }
                    </Route>
                    <Route path="/login" element={<Login />}></Route>
                </Routes>
            </Provider>
        </HashRouter>
    )
}

export default App;






